using System;
using System.Reflection;
using SwinGame;
using System.Collections.Generic;
using Color = System.Drawing.Color;

namespace NeuralNetwork.src
{
    public class GameMain
    {
        public static void Main()
        {
            //Start the audio system so sound can be played
            Audio.OpenAudio();

            //Open the game window
            Graphics.OpenGraphicsWindow("GameMain", 800, 600);
            Graphics.ShowSwinGameSplashScreen();


            Random r = new Random();

            List<Bug> bugs = new List<Bug>(50);
            for (int i = 0; i < 50; i++)
            {
                Bug b = new Bug(r, 400, 300);
                bugs.Add(b);
            }
            //Bug a = new Bug(r, 50, 50);

            //Run the game loop
            while (false == Input.WindowCloseRequested())
            {
                uint ticks = SwinGame.Utils.GetTicks();
                Point2D mp = SwinGame.Input.MousePosition();

                //Fetch the next batch of UI interaction
                Input.ProcessEvents();

                foreach (Bug b in bugs) { b.Update(ticks, r,mp); }

                //Clear the screen and draw the framerate
                Graphics.ClearScreen(Color.White);
                Text.DrawFramerate(0, 0);
                foreach (Bug b in bugs) { b.Draw(ticks); }
                //Draw onto the screen
                Graphics.RefreshScreen();
            }

            //End the audio
            Audio.CloseAudio();

            //Close any resources we were using
            Resources.ReleaseAllResources();
        }
    }
}